package com.dinfo.dmg.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dinfo.dmg.bean.MovieQuery;
import com.dinfo.dmg.bean.p_neg_site_info;
import com.dinfo.dmg.dao.MovieShowDao;
import com.dinfo.dmg.service.MovieShowService;

@Service
public class MovieShowServiceImpl implements MovieShowService {

	@Autowired
	private MovieShowDao movieShowDao;

	public List<p_neg_site_info> selectAllData(MovieQuery query ,int start ,int end) {
		// TODO Auto-generated method stub
		return movieShowDao.selectAllData(query,start, end);
	}

	public List<Map<String,String>> selectMovieType() {
		List<Map<String,String>> maps =new ArrayList<Map<String,String>>();
		List<String> datas =  movieShowDao.selectMovieType();
		for(String data :datas )
		{
			Map<String,String> map = new HashMap<String, String>();
			map.put("id", data);
			map.put("movie_type", data);
			maps.add(map);
		}
		return maps;
	}

	public int selectAllCount(MovieQuery query) {
		// TODO Auto-generated method stub
		return movieShowDao.selectAllCount(query);
	}

	public List<Map<String, String>> selectMovieName() {
		
		List<Map<String, String>> res = new ArrayList<Map<String,String>>();
		List<String> datas =  movieShowDao.selectAllMovieName();
		
		for(String item :datas)
		{
			Map<String,String>  map =  new HashMap<String, String>();
			map.put("text", item);
			map.put("stae", "closed");
			res.add(map);
		}
		return res;
	}

	public Map<String, Object> selectMovieCount() {
		List<Map<String,Object>> datas =   movieShowDao.selectMovieCount();
		List<Map<String,String>> mdata = new ArrayList<Map<String,String>>();
		List<String> items = new ArrayList<String>();
		Map<String,Object> res = new HashMap<String, Object>();
		for( Map<String, Object> data :datas)
		{
			String movieName = data.get("movie_name").toString();
			String count = data.get("count").toString();
			items.add(movieName);
			Map<String,String> map = new HashMap<String, String>();
			map.put("name", movieName);
			map.put("value", count);
			mdata.add(map);
		}
		res.put("items", items);
		res.put("data", mdata);
		return res;
	}
	
	
	
	
}
